﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utilities
{
    public class GraphElement
    {
        public string Name { get; set; }

        public GraphPinCollection InputPins { get; set; }
        public GraphPinCollection OutputPins { get; set; }

        public GraphElement(string name, IEnumerable<GraphPin> inputPins, IEnumerable<GraphPin> outputPins) : this(name)
        {
            InputPins.AddRange(inputPins);
            OutputPins.AddRange(outputPins);
        }
        public GraphElement(string name)
        {
            Name = name;

            InputPins = new GraphPinCollection();
            OutputPins = new GraphPinCollection();
        }

        public void AddInputPin(string name)
        {
            InputPins.Add(new GraphPin(this, name));
        }
        public void AddOutputPin(string name)
        {
            OutputPins.Add(new GraphPin(this, name));
        }

        public override string ToString()
        {
            return Name;
        }
    }

    public class GraphElement<T>
    {
        public string Name { get; set; }
        public T Value { get; set; }

        public GraphPinCollection<T> InputPins { get; set; }
        public GraphPinCollection<T> OutputPins { get; set; }

        public GraphElement(string name, T value, IEnumerable<GraphPin<T>> inputPins, IEnumerable<GraphPin<T>> outputPins) : this(name, value)
        {
            InputPins.AddRange(inputPins);
            OutputPins.AddRange(outputPins);
        }
        public GraphElement(string name, T value)
        {
            Name = name;
            Value = value;

            InputPins = new GraphPinCollection<T>();
            OutputPins = new GraphPinCollection<T>();
        }

        public void AddInputPin(string name)
        {
            InputPins.Add(new GraphPin<T>(this, name));
        }
        public void AddOutputPin(string name)
        {
            OutputPins.Add(new GraphPin<T>(this, name));
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
